RAIS  3.2
C:/Projekte/RAIS/Specific Masks/MessageBox.aspx.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Data;
00030 using System.Configuration;
00031 using System.Collections;
00032 using System.Collections.Generic;
00033 using System.Web;
00034 using System.Web.Security;
00035 using System.Web.UI;
00036 using System.Web.UI.WebControls;
00037 using System.Web.UI.WebControls.WebParts;
00038 using System.Web.UI.HtmlControls;
00039 
00040 using RAIS.Common.MessageManagement;
00041 using RAIS.Common.UserManagement;
00042 using RAIS.ApplicationLogicLayer;
00043 using Messages = System.Collections.Generic.Dictionary<int, RAIS.Common.MessageManagement.Message>;
00044 using ExpandedNodes = System.Collections.Generic.Dictionary<string, bool>;
00045 
00046 namespace RAIS.UI.SpecificMasks
00047 {
00051     public partial class MessageBox : System.Web.UI.Page
00052     {
00053                 //*********************************************************************
00054                 #region Properties
00055 
00058                 protected UserData CurrentUser
00059                 {
00060                         get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; }
00061                 }
00065                 protected Messages ValidationMessages
00066                 {
00067                         get
00068                         {
00069                                 return (Messages)this.ViewState["CurrentMessages"];
00070                         }
00071                         set
00072                         {
00073                                 this.ViewState["CurrentMessages"] = value;
00074                         }
00075                 }
00079                 protected Message CurrentMessage
00080                 {
00081                         get
00082                         {
00083                                 Message message = null;
00084                                 int i = 0;
00085                                 foreach (KeyValuePair<int, Message> kvp in this.ValidationMessages)
00086                                 {
00087                                         if (i++ == GVmessages.SelectedIndex)
00088                                         {
00089                                                 message = kvp.Value;
00090                                                 break;
00091                                         }
00092                                 }
00093                                 return message;
00094                         }
00095                 }
00096                 #endregion
00097                 //*********************************************************************
00098                 #region Event handlers
00099         protected void Page_PreLoad(object sender, EventArgs e)
00100         {
00101             RAIS.UI.Common.PageManagement.TrimTextBoxValues(this);
00102         }
00111         protected void Page_Load(object sender, EventArgs e)
00112         {
00113                         this.Response.Cache.SetNoStore();
00114                         if (this.CurrentUser == null)
00115                                 UI.Common.AccessManagement.SignOut(this);
00116 
00117             this.BTNrelease.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", RAIS.Common.Messages.RELEASE_QUESTION.Replace("'", "\\'")));
00118                         this.LBLsuccessResult.Text = string.Empty;
00119                         this.LBLresult.Text = string.Empty;
00120                         this.LBLnewValuesMessage.Text = string.Empty;
00121                         this.LBLoldValuesMessage.Text = string.Empty;
00122                         this.LBLhistoryValuesMessage.Text = string.Empty;
00123                         
00124                         if (!this.IsPostBack)
00125             {
00126                 this.LBLusernameNoTranslation.Text = this.CurrentUser.Name;
00127                                 //this.TreeView1.Width = new Unit(0);
00128 
00129                 //foreach (DataControlField gridColumn in this.GVmessages.Columns)
00130                 //{
00131                 //    gridColumn.HeaderText = Localisation.Translate(gridColumn.HeaderText
00132                 //        , this.ToString()
00133                 //        , RAIS.Common.Constants.DEFAULT_LANGUAGE
00134                 //        , this.CurrentUser.Language);
00135                 //}
00136                 UI.Common.Localisation.TranslateGridViewHeader(this.GVmessages, this.ToString(), RAIS.Common.Constants.DEFAULT_LANGUAGE, this.CurrentUser.Language);
00137 
00138 
00139                                 this.InitializeCurrentMessages();
00140                                 this.SetReleaseRejectColumnVisibility();
00141 
00142                 // #-#-#
00143                 //this.TreeView1.Visible = UI.Common.UserManagement.GetLevelThreeUsers().ContainsKey(this.CurrentUser.Login);
00144                 UI.Common.PageManagement.InitializePageTreeForCategory(this, this.TreeView1, RAIS.Common.Constants.CATEGORY_NAME_MESSAGEBOX);
00145                 
00146                 
00147 
00148                 //
00149                 this.LBLmessageBox.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT;
00150             }
00151                         UI.Common.Localisation.TranslatePage(this);
00152             UI.Common.PageManagement.InitHelpMainMenu(LBTNdefault);
00153                 }
00160                 protected void GVmessages_RowCommand(object sender, GridViewCommandEventArgs e)
00161                 {
00162                         if (e.CommandName.Equals("ReleaseReject"))
00163                         {
00164                                 int rowIndex = Convert.ToInt32(e.CommandArgument);
00165                                 GVmessages.SelectedIndex = rowIndex;
00166 
00167                                 if (this.CurrentMessage.Type == Message.MessageType.Validation)
00168                                 {
00169                                         this.ActiveReleaseRejectPanel();
00170                                 }
00171                                 else if (this.CurrentMessage.Type == Message.MessageType.AccountRequest)
00172                                 {
00173                                         ExpandedNodes expandedNodes = (ExpandedNodes)this.Session[UI.Common.Constants.SITE_MAP_EXPANSION_STATES];
00174                                         if( expandedNodes == null )
00175                                                 expandedNodes = new ExpandedNodes();
00176                                         if (expandedNodes.ContainsKey("User management"))
00177                                                 expandedNodes["User management"] = true;
00178                                         else
00179                                                 expandedNodes.Add("User management", true);
00180                                         this.Session[UI.Common.Constants.SITE_MAP_EXPANSION_STATES] = expandedNodes;
00181                                         this.Session[UI.Common.Constants.SITE_MAP_SELECTED_NODE] = 
00182                                                 string.Format("User management/{0}~/AddEditUsers_New.aspx"
00183                                                 , UI.Common.Constants.REDIRECTION_URL_PREFIX);
00184 
00185                                         //this.Session[RAIS.UI.Common.Constants.RELEASE_REJECT_SUBMODE_TAG] = true;
00186                                         this.Response.Redirect(string.Format("~/AddEditUsers_New.aspx?id={0}&{1}={2}"
00187                                                 , this.CurrentMessage.RowID
00188                                                 , RAIS.UI.Common.Constants.RELEASE_REJECT_SUBMODE_PARAMETER_NAME
00189                                                 , RAIS.UI.Common.Constants.RELEASE_REJECT_PARAMETER_VALUE));
00190                                 }
00191                         }
00192                 }
00193 
00194                 protected void GVmessages_PageIndexChanging(object sender, GridViewPageEventArgs e)
00195                 {
00196                         this.InitializeCurrentMessages();
00197 
00198                         // Set new page index
00199                         this.GVmessages.PageIndex = e.NewPageIndex;
00200 
00201                         // Bind data to the GridView
00202                         this.GVmessages.DataBind();
00203                 }
00213         protected void BTNrelease_Click(object sender, EventArgs e)
00214         {
00215                         bool success;
00216                         string actionMessage = string.Empty;
00217 
00218                         success = UI.Common.MessageManagement.ReleaseChanges(this.CurrentMessage, ref actionMessage, this.CurrentUser);
00219 
00220                         if (success)
00221                         {
00222                                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLsuccessResult,
00223                                                                                                                                                 actionMessage,
00224                                                                                                                                                 success);
00225                                 this.InitializeCurrentMessages();
00226 
00227                                 GVmessages.SelectedIndex = -1;
00228                                 PNLmessages.Visible = true;
00229                                 PNLsubmission.Visible = false;
00230                                 PNLrejectmessage.Visible = false;
00231                                 DIVtreeView.Visible = true;
00232                         }
00233                         else
00234                         {
00235                                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00236                                                                                                                                                 actionMessage,
00237                                                                                                                                                 success);
00238                         }
00239                 }
00247                 protected void BTNreject_Click(object sender, EventArgs e)
00248                 {
00249                         PNLmessages.Visible = false;
00250                         PNLsubmission.Visible = false;
00251                         PNLrejectmessage.Visible = true;
00252                         DIVtreeView.Visible = true;
00253                 }
00261                 protected void BTNcancel_Click(object sender, EventArgs e)
00262                 {
00263                         GVmessages.SelectedIndex = -1;
00264 
00265                         PNLmessages.Visible = true;
00266                         PNLsubmission.Visible = false;
00267                         PNLrejectmessage.Visible = false;
00268                         DIVtreeView.Visible = true;
00269                 }
00277                 protected void BTNsend_Click(object sender, EventArgs e)
00278                 {
00279                         PNLmessages.Visible = false;
00280                         PNLsubmission.Visible = true;
00281                         PNLrejectmessage.Visible = false;
00282                         DIVtreeView.Visible = true;
00283 
00284                         bool success;
00285                         string actionMessage = string.Empty;
00286 
00287                         this.CurrentMessage.Comment = TXTreason.Text;
00288 
00289                         success = UI.Common.MessageManagement.RejectChanges(this.CurrentMessage, ref actionMessage, this.CurrentUser);
00290 
00291                         if (success)
00292                         {
00293                                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLsuccessResult,
00294                                                                                                                                                 actionMessage,
00295                                                                                                                                                 success);
00296                                 this.InitializeCurrentMessages();
00297 
00298                                 GVmessages.SelectedIndex = -1;
00299                                 PNLmessages.Visible = true;
00300                                 PNLsubmission.Visible = false;
00301                                 PNLrejectmessage.Visible = false;
00302                                 DIVtreeView.Visible = true;
00303                         }
00304                         else
00305                         {
00306                                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00307                                                                                                                                                 actionMessage,
00308                                                                                                                                                 success);
00309                         }
00310                 }
00317                 protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
00318                 {
00319                         UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1);
00320                 }
00327                 protected void LBTNlogout_Click(object sender, EventArgs e)
00328                 {
00329                         UI.Common.AccessManagement.SignOut(this);
00330                 }
00339                 protected void BTNview_Click(object sender, EventArgs e)
00340                 {
00341 
00342                 }
00343 
00352                 protected void BTNreleasereject_Click(object sender, EventArgs e)
00353                 {
00354 
00355                 }
00356                 #endregion
00357                 //*********************************************************************
00358         #region Private helper methods
00359                 protected void InitializeCurrentMessages()
00360                 {
00361                         this.ValidationMessages = UI.Common.MessageManagement.GetInputMessagesByUser(CurrentUser);
00362                         this.GVmessages.DataSource = this.ValidationMessages.Values;
00363                         this.GVmessages.DataBind();
00364                 }
00365 
00366                 protected void ActiveReleaseRejectPanel()
00367                 {
00368                         PNLmessages.Visible = false;
00369                         PNLsubmission.Visible = true;
00370                         PNLrejectmessage.Visible = false;
00371                         BTNrelease.Enabled = true;
00372 
00373                         ValidationData validationData =
00374                                 UI.Common.MessageManagement.GetValidationDataByMessage(this.CurrentMessage, this.CurrentUser);
00375 
00376                         LBLsubmission.Text = string.Format("Submission information - {0} row"
00377                                 , validationData.Message.ModificationData.VisibleName);
00378 
00379                         if (validationData.Message.Modification == Message.ModificationType.Edit
00380                                 || validationData.Message.Modification == Message.ModificationType.Add
00381                                         && validationData.Table.WithHistoryValidation)
00382                         {
00383                 DIVtarget.Attributes["class"] = "doublePanelTargetDiv";
00384                 FLSsubmission.Attributes["class"] = "doubleflssubmission";
00385                                 DIVtreeView.Visible = false;
00386                         }
00387                         else
00388                         {
00389                 FLSsubmission.Attributes["class"] = "flssubmission";
00390                 DIVtarget.Attributes["class"] = "targetdiv";
00391                                 DIVtreeView.Visible = true;
00392                         }
00393 
00394                         if (validationData.Message.Modification == Message.ModificationType.Add)
00395                         {
00396                                 FLSold.Visible = false;
00397                         }
00398                         else
00399                         {
00400                                 FLSold.Visible = true;
00401 
00402                                 if (validationData.CurrentRowValues != null)
00403                                 {
00404                                         DynamicMaskControlsManagement.AddFieldControls(this.TBLoldFieldsValues, validationData.CurrentRowValues, 1, null);
00405                                         DynamicMaskControlsManagement.InitializeFieldControls(this.TBLoldFieldsValues, validationData.CurrentRowValues);
00406                                         DynamicMaskControlsManagement.SetFieldControlsEnabled(this.TBLoldFieldsValues, validationData.ValidationRowValues, false);
00407                                 }
00408                                 else
00409                                 {
00410                                         LBLoldValuesMessage.Text = RAIS.Common.Messages.ALREADY_DELETED_ROW_MESSAGE;
00411                                         LBLoldValuesMessage.ForeColor = System.Drawing.Color.Red;
00412                                         BTNrelease.Enabled = false;
00413                                 }
00414                         }
00415 
00416                         if (validationData.Message.Modification == Message.ModificationType.Delete)
00417                         {
00418                                 FLSnew.Visible = false;
00419                         }
00420                         else
00421                         {
00422                                 FLSnew.Visible = true;
00423 
00424                                 if (validationData.ValidationRowValues != null)
00425                                 {
00426                                         DynamicMaskControlsManagement.AddFieldControls(this.TBLnewFieldsValues, validationData.ValidationRowValues, 2, null);
00427                                         DynamicMaskControlsManagement.InitializeFieldControls(this.TBLnewFieldsValues, validationData.ValidationRowValues);
00428                                         DynamicMaskControlsManagement.SetFieldControlsEnabled(this.TBLnewFieldsValues, validationData.ValidationRowValues, false);
00429                                 }
00430                                 else
00431                                 {
00432                                         LBLnewValuesMessage.Text = RAIS.Common.Messages.DOES_NOT_EXIST_VALIDATION_DATA;
00433                                         LBLnewValuesMessage.ForeColor = System.Drawing.Color.Red;
00434                                 }
00435                         }
00436 
00437                         if (validationData.Message.Modification == Message.ModificationType.Add
00438                                 && validationData.Table.WithHistoryValidation)
00439                         {
00440                                 FLShistory.Visible = true;
00441                                 LBLnewValues.Text = "Main Row Values";
00442 
00443                                 if (validationData.ValidationHistoryRowValues != null)
00444                                 {
00445                                         DynamicMaskControlsManagement.AddFieldControls(this.TBLhistoryFieldsValues, validationData.ValidationHistoryRowValues, 3, null);
00446                                         DynamicMaskControlsManagement.InitializeFieldControls(this.TBLhistoryFieldsValues, validationData.ValidationHistoryRowValues);
00447                                         DynamicMaskControlsManagement.SetFieldControlsEnabled(this.TBLhistoryFieldsValues, validationData.ValidationHistoryRowValues, false);
00448                                 }
00449                                 else
00450                                 {
00451                                         LBLhistoryValuesMessage.Text = RAIS.Common.Messages.DOES_NOT_EXIST_VALIDATION_DATA;
00452                                         LBLhistoryValuesMessage.ForeColor = System.Drawing.Color.Red;
00453                                 }
00454                         }
00455                         else
00456                         {
00457                                 FLShistory.Visible = false;
00458                                 LBLnewValues.Text = "New Values";
00459                         }
00460                 }
00461 
00462                 protected void SetReleaseRejectColumnVisibility()
00463                 {
00464                         foreach (DataControlField column in GVmessages.Columns)
00465                         {
00466                                 if (column is ButtonField && ((ButtonField)column).CommandName == "ReleaseReject")
00467                                         column.Visible = (CurrentUser.Validator 
00468                                                 || CurrentUser.FunctionalRole.Type == FunctionRole.FunctionRoleType.Administrator);
00469                         }
00470                 }
00471         #endregion
00472     }
00473 }